require('./PagePaymanage.styl');

const reactMixin = require('react-mixin');
const Actions = require('./actions');
const Store = require('./store');
import { Control } from 'react-keeper';
const GirdView = require('components/girdview');
import Panel from 'components/panel'
import Menu from 'components/menu'
var paths = [{ path: "payment", title: "支付管理", id: 'index0', tabTitles: "支付审批 进度跟踪" }];
const ui = require('clientConfig/util/jsapi/ui');
class Paymanage extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            
        };
        this.action = !window.isBp ? [
            {
                content: '支付计划',
                icon: "pay/payapply.svg",
                path: "/home/payment/payplan"
            }, {
                content: '支付申请',
                icon: "pay/payplan.svg",
                path: "/home/payment/paymanagesub"
            }] : [{
                content: '支付流转',
                icon: "pay/paytransfer.svg",
                path: "/home/payment/paytransfer"
            }];
        if (Control.state) {
            if (Control.state.origin_title == "支付进度") {
                this.activenum = 0;
                paths = [{ path: "payment", title: "支付管理", id: 'index0', tabTitles: "进度跟踪" }];
            }
        } else {
            paths = [{ path: "payment", title: "支付管理", id: 'index0', tabTitles: "支付审批 进度跟踪" }];
            this.activenum = 0;
        }
        this.handlePlusClick = this.handlePlusClick.bind(this);
    }

    handlePlusClick() {
        this.setState({
            show: true,
        })
    }
    render() {
        let girdItems = [{ title: "待我审批的", hashPath: "/home/payment/pending", src: "pending", homesvg: 'workplan0_svg1' }, { title: "我发起的", hashPath: "/home/payment/sponsored", src: "sponsored", homesvg: "workplan0_svg2" }, { title: "抄送我的", hashPath: "/home/payment/copy", src: "copy", homesvg: "workplan0_svg3" },
        { title: "变更申请", hashPath: "/home/payment/changereq", src: "changereq", homesvg: "workplan0_svg4" }, { title: "变更记录", hashPath: "/home/payment/changerecord", src: "changerecord", homesvg: "workplan0_svg5" }];

        let pro_girdItems = !window.isBp ? [{ title: "项目总览", hashPath: "/home/payment/progresstrack", src: "progresstrack", homesvg: 'workplan1_svg1' }, { title: "单个项目", hashPath: "/home/payment/singleproject", src: "singleproject", homesvg: "workplan1_svg2" }]
            : [{ title: "项目总览", hashPath: "/home/payment/progresstrack", src: "progresstrack", homesvg: 'workplan1_svg1' }, { title: "单个项目", hashPath: "/home/payment/singleproject", src: "singleproject", homesvg: "workplan1_svg2" }, { title: "支付统计", hashPath: "/home/payment/payStatistics", src: "payStatistics", homesvg: "workplan1_svg3" }];
        return (
            <div className="paymanage">
                {paths.map((item, index) => {
                    const ContentSvg = require(`images/svg/mangement/${item.path}.svg`);
                    return (
                        <Panel
                            activenum={this.activenum}
                            title={item.title}
                            Key={item.path}
                            active
                            tabTitles={item.tabTitles}
                            cbPlus={this.handlePlusClick}>
                            <ContentSvg className="content-svg"/>
                            {!Control.state && <GirdView girdItems={girdItems} path={item.path} />}
                            <GirdView girdItems={pro_girdItems} path={item.path} />
                        </Panel>
                    );
                })
                }
                <Menu item={this.action} show={this.state.show} />
            </div>
        );
    }

    componentWillMount() {
        ui.setTitle({ title: "IT项目管理信息系统" });
    }

    componentDidMount() { }

    componentWillReceiveProps(nextProps) { }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) { }

    componentDidUpdate(prevProps, prevState) { }

    componentWillUnmount() {

    }
}

reactMixin.onClass(Paymanage, Reflux.connect(Store, 'Paymanage'));

module.exports = Paymanage;
